﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 易保全
{
    public partial class BorderForm : Form
    {
        public BorderForm()
        {
            InitializeComponent();
            this.Width=Screen.AllScreens[0].Bounds.Width;
            this.Height = Screen.AllScreens[0].Bounds.Height;
        }
        private Graphics g;   //主画面
        private bool isMouthDown;       //判断鼠标是否按下 
        private Point downPoint;        //鼠标按下的点 
        private void FrmBorder_MouseDown(object sender, MouseEventArgs e)
        {
           int i = e.Clicks;
            if (e.Clicks < 2)
            {
                downPoint = MousePosition;
                isMouthDown = true;
            }
        }

        private void FrmBorder_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouthDown)
            {
                try
                {
                    //矩形
                    int x = Math.Min(downPoint.X, MousePosition.X);
                    int y = Math.Min(downPoint.Y, MousePosition.Y);
                    int pic_width = Math.Abs(MousePosition.X - downPoint.X);
                    int pic_height = Math.Abs(MousePosition.Y - downPoint.Y);
                    g = CreateGraphics();
                    g.Clear(BackColor);
                    g.DrawRectangle(new Pen(Brushes.Red), x, y, pic_width, pic_height);
                    g.FillRectangle(Brushes.CornflowerBlue, x + 1, y + 1, pic_width - 1, pic_height - 1);
                    //Tip跟随鼠标
                    int tip_x = Math.Min(Screen.PrimaryScreen.Bounds.Size.Width - this.lblInfo.Width, MousePosition.X);
                    int tip_y = Math.Min(Screen.PrimaryScreen.Bounds.Size.Height - this.lblInfo.Height, MousePosition.Y);
                    this.lblInfo.Location = new Point(tip_x, tip_y);
                    this.lblInfo.Visible = true;
                }
                catch 
                {
                }
            }
        }

        private void FrmBorder_MouseUp(object sender, MouseEventArgs e)
        {
            this.lblInfo.Visible = true;
        }

        private void lblInfo_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
